import { dirname, resolve } from 'path';
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';

if (typeof __dirname === 'undefined') {
  globalThis.__dirname = dirname(fileURLToPath(import.meta.url))
}

export function loadCorpus(src) {
  // console.log(dirname(src));
  const path = resolve(__dirname, '..', src);
  let data = readFileSync(path, { encoding: 'utf-8' });
  data = JSON.parse(data);
  // console.log(data);
  return data
}